<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="../../../common/common-easyui.jspf" %>
<!DOCTYPE html >
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>试卷维护</title>
</head>
<body>
<table title="试卷预览" class="easyui-datagrid" style="width:100%;height:100%"
       data-options="
			url:'paperInfoController?flag=query',			
			rownumbers:'true',
			 fitColumns:'true' ,
			 singleSelect:'true'"
>
    <thead>
    <tr>
        <th data-options="field:'paperId'" width="50">试卷编号</th>
        <th data-options="field:'paperName'" width="50">试卷名称</th>
        <th data-options="field:'courseId'" width="50">科目</th>
        <th data-options="field:'examTime'" width="50">考试时长</th>
        <th data-options="field:'teaId'" width="50">老师编号</th>
        <th width="50" data-options="
					field:'paperDate',
				    formatter:function(value) {
						return getTimer(value);
					 }
				">出题时间
        </th>
        <th data-options="field:'passScore'" width="50">通过分数</th>
        <th data-options="field:'ruleId'" width="50">组卷规则编号</th>
        <th width="50" data-options="
					field:'testId',
				    formatter:function(value) {
				    	if(value==1){
				    		return '手动组卷';
				    	}else{				    	
							return '随机组卷';
				    	}
					 }
				">组卷规则
        </th>
        <th id="scan" width="50" data-options="
					field:'opt',
				    formatter:function(value,row) {
						return scan(row.paperId);
					}
				">操作
        </th>
    </tr>
    </thead>
</table>
<!-- 弹出层 -->
<div id="promptDiv" style="display:none;"></div>
<script type="text/javascript">
    //添加a标签
    function scan(paperId) {

        var btn = "<a onclick='scanPaper(" + paperId + ");' href='javascript:void(0)'>预览试卷</a>";
        return btn;
    }
    //预览试卷
    function scanPaper(paperId) {
        $("#promptDiv").dialog({
            title: "题型窗口",
            width: '100%',
            height: '100%',
            modal: true,
            href: 'paperInfoController?flag=scan_paper&paperId=' + paperId,
            buttons: [{
                text: "确定",
                handler: function () {
                    // 关闭模态
                    $('#promptDiv').dialog('close');
                }
            }]
        });
    }

    // 时间处理
    function getTimer(value) {
        // 创建一个日期对象
        // new 把该对象放到内存空间中存储起来
        var date = new Date(value);
        // 获取年份
        var year = date.getFullYear();
        // 获取月份
        var month = date.getMonth() + 1;
        // 获取天数
        var day = date.getDate();

        // 获取小时
        var hours = handler(date.getHours());
        // 获取分钟数
        var minutes = handler(date.getMinutes());
        // 获取秒数
        var seconds = handler(date.getSeconds());

        var currentTime = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;

        return currentTime;
    }

    /*定义处理如果时间小于10前面加0的函数*/
    function handler(time) {

        if (time < 10) {
            time = "0" + time;
        }

        // 返回当前格式化后的字符串
        return time;

    }
</script>
</body>
</html>